home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 020a / djgdrv.zip / TSENG4K.ASM < prev    next >
Assembly Source File  |  1991-03-06  |  4KB  |  203 lines

  1. ; This is file TSENG4K.ASM
  2. ;
  3. ; Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954
  4. ;
  5. ; This file is distributed under the terms listed in the document
  6. ; "copying.dj", available from DJ Delorie at the address above.
  7. ; A copy of "copying.dj" should accompany this file; if not, a copy
  8. ; should be available from where this file was obtained.  This file
  9. ; may not be distributed without a verbatim copy of "copying.dj".
  10. ;
  11. ; This file is distributed WITHOUT ANY WARRANTY; without even the implied
  12. ; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. ;
  14.  
  15. cseg    segment    byte public 'code'
  16.     assume    cs:cseg, ds:cseg, es:cseg, ss:nothing
  17.     .386p
  18.  
  19.     dw    offset init_routine
  20.     dw    offset paging_routine
  21.     dw    1    ; set to 1 if separate read & write windows or
  22.             ; only 64K of video RAM (ie: no paging)
  23.  
  24. def_tw    dw    80    ; filled in by go32 if GO32 env. var. is set
  25. def_th    dw    25
  26. def_gw    dw    640
  27. def_gh    dw    480
  28.  
  29. ;--------------------------------------------------------------------------
  30. ; Entry: AX=mode selection
  31. ;        0=80x25 text
  32. ;        1=default text
  33. ;        2=text CX cols by DX rows
  34. ;        3=biggest text
  35. ;        4=320x200 graphics
  36. ;        5=default graphics
  37. ;        6=graphics CX width by DX height
  38. ;        7=biggest non-interlaced graphics
  39. ;        8=biggest graphics
  40. ;
  41. ; NOTE: This runs in real mode, but don't mess with the segment registers.
  42. ;
  43. ; Exit:  CX=width (in pixels or characters)
  44. ;        DX=height
  45.  
  46. init_table    label    word
  47.     dw    offset init_0
  48.     dw    offset init_1
  49.     dw    offset init_2
  50.     dw    offset init_3
  51.     dw    offset init_4
  52.     dw    offset init_5
  53.     dw    offset init_6
  54.     dw    offset init_7
  55.     dw    offset init_8
  56.  
  57. init_routine    proc    far
  58.     cmp    ax,8
  59.     jbe    valid_req
  60.     ret
  61. valid_req:
  62.     shl    ax,1
  63.     mov    bx,ax
  64.     jmp    init_table[bx]
  65.  
  66. init_0: ; 80x25 text
  67.     mov    ax,3
  68.     int    10h
  69.     mov    cx,80
  70.     mov    dx,25
  71.     ret
  72.  
  73. init_1: ; default text
  74.     mov    cx,def_tw
  75.     mov    dx,def_th
  76.     jmp    init_2
  77.  
  78. init_2_table    label    word
  79.     dw    01h, 40, 25
  80.     dw    03h, 80, 25
  81.     dw    23h, 132, 25
  82.     dw    24h, 132, 28
  83.     dw    22h, 132, 44
  84.     dw    61h, 132, 50
  85. init_2_tend    label    word
  86.  
  87. init_2: ; CX*DX text
  88.     mov    si,offset init_2_table
  89. init_2a:
  90.     cmp    [si+2],cx
  91.     jb    init_2b
  92.     cmp    [si+4],dx
  93.     jb    init_2b
  94.     ; got a big enough one!
  95.     jmp    init_2c
  96. init_2b:
  97.     cmp    si,offset init_2_tend - 6
  98.     je    init_2c
  99.     add    si,6
  100.     jmp    init_2a
  101. init_2c:
  102.     mov    ax,[si]
  103.     push    si
  104.     int    10h
  105.     pop    si
  106.     mov    cx,[si+2]
  107.     mov    dx,[si+4]
  108.     ret
  109.  
  110. init_3: ; biggest text
  111.     mov    ax,[init_2_tend-6]
  112.     int    10h
  113.     mov    cx,[init_2_tend-4]
  114.     mov    dx,[init_2_tend-2]
  115.     ret
  116.  
  117. init_4: ; 320x200 graphics
  118.     mov    ax,13h
  119.     int    10h
  120.     mov    cx,320
  121.     mov    dx,200
  122.     ret
  123.  
  124. init_5: ; default graphics - should be 640x480 if supported
  125.     mov    cx,def_gw
  126.     mov    dx,def_gh
  127.     jmp    init_6
  128.  
  129. init_6_table    label    word
  130.     dw    13h, 320, 200
  131.     dw    2dh, 640, 350
  132.     dw    78h, 640, 400
  133.     dw    2eh, 640, 480
  134.     dw    30h, 800, 600
  135.     dw    38h, 1024, 768
  136. init_6_tend    label    word
  137.  
  138. init_6: ; CX*DX graphics
  139.     mov    si,offset init_6_table
  140. init_6a:
  141.     cmp    [si+2],cx
  142.     jb    init_6b
  143.     cmp    [si+4],dx
  144.     jb    init_6b
  145.     ; got a big enough one!
  146.     jmp    init_6c
  147. init_6b:
  148.     cmp    si,offset init_6_tend - 6
  149.     je    init_6c
  150.     add    si,6
  151.     jmp    init_6a
  152. init_6c:
  153.     mov    ax,[si]
  154.     push    si
  155.     int    10h
  156.     pop    si
  157.     mov    cx,[si+2]
  158.     mov    dx,[si+4]
  159.     ret
  160.  
  161. init_7: ; biggest non-interlaced graphics
  162.     mov    ax,30h
  163.     int    10h
  164.     mov    cx,800
  165.     mov    dx,600
  166.     ret
  167.  
  168. init_8: ; biggest graphics
  169.     mov    ax,38h
  170.     int    10h
  171.     mov    cx,1024
  172.     mov    dx,768
  173.     ret
  174.  
  175. init_routine    endp
  176.  
  177. ;--------------------------------------------------------------------------
  178. ; Entry: AH=read page
  179. ;        AL=write page
  180. ;
  181. ; NOTE: This runs in protected mode!  Don't mess with the segment registers!
  182. ; This code must be relocatable and may not reference any data!
  183. ;
  184. ; Exit: VGA configured.
  185. ;       AX,BX,CX,DX,SI,DI may be trashed
  186.  
  187.     assume    ds:nothing, es:nothing
  188.  
  189. paging_routine    proc    far
  190.     and    al,0fh
  191.     shl    ah,4
  192.     and    ah,0f0h
  193.     or    al,ah
  194.     mov    dx,03cdh
  195.     out    dx,al
  196.     ret
  197. paging_routine    endp
  198.  
  199. ;--------------------------------------------------------------------------
  200.  
  201. cseg    ends
  202.     end
  203.